Skip to content

Fixing bug with single and double quotes inside values#7

Open
DmitryMK wants to merge 1 commit into
mainfrom
feature/autoRefresh
Open

Fixing bug with single and double quotes inside values#7
DmitryMK wants to merge 1 commit into
mainfrom
feature/autoRefresh

Conversation

@DmitryMK

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses parsing/serialization edge cases where string values contain embedded single or double quotes, improving the filter language’s ability to round-trip such values reliably.

Changes:

  • Extend string token regex to accept escaped quotes within quoted literals.
  • Update parsing to unescape embedded quotes and update serialization to escape embedded double quotes.
  • Add tests covering validation, parsing, and stringification for values containing escaped quotes; bump version to 0.2.1 and update changelog.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/utils/filterRegex.ts Expands itemString regex to allow escaped quotes inside quoted string literals.
src/utils/filterExpression.ts Unescapes embedded quotes during parsing; adjusts condition reading to respect escape characters; escapes " during serialization.
test/validateFilterString.test.ts Adds validation tests for filter strings containing escaped quotes.
test/stringToFilter.test.ts Adds parsing + round-trip tests for escaped quotes in string values.
test/filterToString.test.ts Adds serialization test to ensure embedded " are escaped in output.
package.json Bumps package version to 0.2.1.
CHANGELOG.md Adds 0.2.1 entry describing the quote-handling bugfix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 119 to 123
return splitCommaRespectingQuotes(items).map((item) => {
const match = item.match(/^(["'])(.*)\1$/s);
if (match === null) {
throw new Error(`Invalid string value ${item}`);
}
Comment on lines +454 to +455
const escapedValues = value.map((v) => (v as string).replace(/"/g, '\\"'));
valueString = `("${escapedValues.join('", "')}")`;
Comment on lines +460 to +462
// Escape double quotes in the string value
const escapedValue = value.replace(/"/g, '\\"');
valueString = `"${escapedValue}"`;
Comment on lines +108 to +111
const quote = match[1];
const value = match[2];
const escapedQuote = quote === '"' ? '\\\\"' : "\\\\'";
return value.replace(new RegExp(escapedQuote, "g"), quote);
Comment on lines +124 to +127
const quote = match[1];
const value = match[2];
const escapedQuote = quote === '"' ? '\\\\"' : "\\\\'";
return value.replace(new RegExp(escapedQuote, "g"), quote);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants